﻿/* SQL code highlighting
 * From
 * http://www.istaysharp.net/index.php?title=SQL_Syntax_Highlighting_-_The_Microsoft_Way&printable=yes    
 */
using System;
using System.Runtime.InteropServices;

namespace SQLParser
{
    [Guid("969F3D60-F816-11D0-B9C3-0020AFC2CD36")]
    public enum SyntaxConstants
    {
        SqlServer = 1,
        Oracle = 4
    }

    public class SQLParser
    {
        IVBSQLParser sqlParser = null;

        [ComImport, Guid("8F6C7662-E8A1-11D0-B9B3-2A92D0000000")]
        internal class vbSQLParser
        {
        }

        [Guid("8F6C7661-E8A1-11D0-B9B3-2A92D0000000"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        internal interface IVBSQLParser
        {
            [DispId(1)]
            string ParseSQLSyntax(string sql, SyntaxConstants syntax);
        }

        public SQLParser()
        {
            sqlParser = (IVBSQLParser)new vbSQLParser();
        }

        public string Parse(string sql, SyntaxConstants syntax)
        {
            return sqlParser.ParseSQLSyntax(sql, syntax);
        }
    }
}
